﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using ChBusiness.User;
using ChBusiness.Common;

namespace ChBusiness.InterfaceClass
{
    /// <summary>
    /// 地信中心接口用户信息操作类
    /// </summary>
    public class DXUserClass
    {
        /// <summary>
        /// 根据列名获取comment
        /// </summary>
        /// <param name="strColumnName">列名.</param>
        /// <returns></returns>
        public string GetComment(string strColumnName)
        {
            DataTable commentTable = new DataTable();
            OracleSystemOperation sysOperation = new OracleSystemOperation();
            commentTable = sysOperation.GetFieldsComment("SYS_USER");
            DataRow[] dr = commentTable.Select("column_name='" + strColumnName + "'");
            return dr[0]["comments"].ToString();
        }
        /// <summary>
        /// 获取用户信息的XML
        /// </summary>
        /// <param name="strUserId">用户ID.</param>
        /// <returns></returns>
        public string GetSpResult(string strUserId)
        {
            DataTable tempTable = new DataTable();
            tempTable = UserHandle.GetUser(strUserId);

            string strTemp = string.Empty;
            strTemp = @"<ResultSet>
                <Record>";
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["USERID"].ToString(),
                GetComment("USERID"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["USERPWD"].ToString(),
                GetComment("USERPWD"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["USERNAME"].ToString(),
                GetComment("USERNAME"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["TEL"].ToString(),
                GetComment("TEL"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["MOBILE"].ToString(),
                GetComment("MOBILE"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["ZJLB"].ToString(),
                GetComment("ZJLB"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["ZJHM"].ToString(),
                GetComment("ZJHM"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["CZ"].ToString(),
                GetComment("CZ"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["EMAIL"].ToString(),
                GetComment("EMAIL"));
            strTemp += string.Format("<[{1}]>{0}</{1}>", tempTable.Rows[0]["YZBM"].ToString(),
                GetComment("YZBM"));
            strTemp += "</Record></ResultSet>"; 

            return strTemp;

        }
    }
}
